﻿using System.Collections.Generic;
using CoreEx.Samples.DomainModel;
using LinFu.IoC.Configuration;
using LinFu.IoC.Interfaces;
using LinFu.IoC;
namespace CoreEx.Samples.ServiceFacade.Implementation
{
    [Implements(typeof(ICustomerService))]
    public class CustomerService : ICustomerService, IInitialize
    {
        private IServiceContainer _serviceContainer;
        
        
        public IList<Customer> GetCustomers()
        {
            var customer1 = _serviceContainer.GetService<Customer>();
            customer1.CustomerID = "ALFKI";
            var customer2 = _serviceContainer.GetService<Customer>();
            customer2.CustomerID = "ANTON";
            return new List<Customer>(new []{customer1,customer2});
        }

        public IList<Customer> GetCustomersByCategory(int category)
        {
            return GetCustomers();
        }

        public void Initialize(IServiceContainer source)
        {
            _serviceContainer = source;
        }
    }
}
